#pragma once

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <cstdio>


// Class used by client to communicate with server.
class Net
{
public:
	// Initializes sockets.
	Net();

	// Does the cleanup.
	virtual ~Net();

	// Connetcs to server. Hostname can be a name or an ip address.
	bool	Connect(const char* Hostname, const char* Port);

	// Disconnects.
	void	Disconnect();

	// Sends data. Wrapper to "send" function.
	int		Send(const char* Data, int Length);

	// Receives data. Wrapper to "recv" function.
	int		Recv(char* Buffer, int Length);

private:
	SOCKET			s;			// Socket used to communicate.
	WSADATA			wsaData; 
	struct addrinfo	*server,	// Server info structure.
					hints;		// Requested socket.
};
